# Moths - an environment for mathy calculations
# Copyright (C) 2006 Mike Sutjipto
# Licensed under the GPL

module Moths
  
  # Wraps the functionality of an interpreter
  #
  class Interpreter
    @env
    
    def initialize(env = nil)
      if nil == env then 
        @env = Environment.new
      else
        @env = env
      end
    end

    # Takes in a string, and performs the steps necessary to be
    # able to evaluate it into something
    #
    def eval_string(str)
      tokenizer = Tokenizer.new(str)
      parser = Parser.new
      parsed = parser.parse(tokenizer, @env)

      return parsed.eval(@env).to_s
    end
  end
  
end
